package com.hzdl.car.sqlprovider;

import com.hzdl.car.util.Common;
import com.hzdl.car.vo.CheckVo;
import org.apache.ibatis.jdbc.SQL;

public class CheckSqlProvider {
    public String findCheck(CheckVo checkVo){
        return new SQL(){{
            SELECT("*");
            FROM("bus_check");
            if(!Common.isEmpty(checkVo.getCheckId())){
                WHERE("checkId like concat('%',#{checkId},'%')");
            }
            if(!Common.isEmpty(checkVo.getCheckDesc())){
                WHERE("checkDesc like concat('%',#{checkDesc},'%')");
            }
            if(!Common.isEmpty(checkVo.getProblem())){
                WHERE("problem like concat('%',#{problem},'%')");
            }
            if(!Common.isEmpty(checkVo.getRentId())){
                WHERE("rentId like concat('%',#{rentId},'%')");
            }

            if(checkVo.getStartDate()!=null){
                WHERE("checkDate >= #{startDate}");
            }
            if(checkVo.getEndDate()!=null){
                WHERE("checkDate <= #{endDate}");
            }



        }}.toString();
    }
}
